<template>
	<view>
		<button style="margin-top: 50px;" open-type="share" @click="share">分享</button>

		<button style="margin-top: 50px;" @click="getLocation">获取经纬度</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		onShow: function() {
			//获取在app.vue中定义的全局数据
			this.tips = getApp().globalData.text
			console.log(getApp().globalData.text);

		},
		methods: {
			//允许转发的默认函数
			onShareAppMessage() {},

			// 分享操作
			share() {
				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					type: 1,
					summary: "我正在使用HBuilderX开发uni-app，赶紧跟我一起来体验！",
					success: function(res) {
						console.log("success:" + JSON.stringify(res));
					},
					fail: function(err) {
						console.log("fail:" + JSON.stringify(err));
					}
				});
			},

			//经纬度
			getLocation() {
				uni.getLocation({
					type: 'wgs84',
					success: function(res) {
						console.log(res);
					},
					fail: function(error) {
						console.error('获取位置失败：', error);
					}
				});
			}

		}
	}
</script>

<style>

</style>